package com.ht.mt.sric.entity;

import java.io.Serializable;

import java.math.BigDecimal;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@NamedQueries({ @NamedQuery(name = "Ubigeo.findAll", query = "select o from Ubigeo o") })
@Table(name = "UBIGEO")
public class Ubigeo implements Serializable {
    private static final long serialVersionUID = -8212863374084186227L;
    @Id
    @SequenceGenerator(name = "SQ_UBIGEO", sequenceName = "SQ_UBIGEO", allocationSize = 1)
    @GeneratedValue(generator = "SQ_UBIGEO")
    
    @Column(name = "ID_UBGO", nullable = false)
    private Integer idUbgo;
    @Column(name = "NMBR_UBGO", length = 50)
    private String nmbrUbgo;
    @OneToMany(mappedBy = "ubigeo", cascade = { CascadeType.PERSIST, CascadeType.MERGE })
    private List<Tramo> tramoList;

    public Ubigeo() {
    }

    public Ubigeo(Integer idUbgo, String nmbrUbgo) {
        this.idUbgo = idUbgo;
        this.nmbrUbgo = nmbrUbgo;
    }

    public Integer getIdUbgo() {
        return idUbgo;
    }

    public void setIdUbgo(Integer idUbgo) {
        this.idUbgo = idUbgo;
    }

    public String getNmbrUbgo() {
        return nmbrUbgo;
    }

    public void setNmbrUbgo(String nmbrUbgo) {
        this.nmbrUbgo = nmbrUbgo;
    }

    public List<Tramo> getTramoList() {
        return tramoList;
    }

    public void setTramoList(List<Tramo> tramoList) {
        this.tramoList = tramoList;
    }

    public Tramo addTramo(Tramo tramo) {
        getTramoList().add(tramo);
        tramo.setUbigeo(this);
        return tramo;
    }

    public Tramo removeTramo(Tramo tramo) {
        getTramoList().remove(tramo);
        tramo.setUbigeo(null);
        return tramo;
    }
}
